<template>
  <div id="OrdersTitle">
    <v-details
      :inputConfig="inputConfig"
      :detailData="inputData"
      :rules="rules"
      @pop="setdata"
    ></v-details>
  </div>
</template>

<script>
import details from "commons/Detail";
import baseMixin from "@/mixins/BaseMixin";

export default {
  props: {
    inputData: {
      type: Object,
    },
  },
  mixins: [baseMixin],
  name: "OrdersTitle",
  data() {
    return {
      rules: {
        gatherkey: [{ required: true, trigger: "blur" }],
        addwho: [{ required: true, trigger: "blur" }],
      },
      addflag: false,
    };
  },
  computed: {
    inputConfig() {
      return [
        [
          {
            type: "input",
            label: this.$t('out.gatherkey'),
            disabled: true,
            props: "gatherkey",
          },
          {
            type: "textarea",
            label: this.$t("app.remark"),
            props: "note",
            disabled: this.addflag,
          },
        ],
        [
          {
            type: "input",
            label: this.$t("app.createName"),
            disabled: true,
            props: "addwho",
          },
        ],
        [
          {
            type: "date",
            label: this.$t('out.addDate'),
            disabled: true,
            props: "adddate",
          },
        ],
        [
          {
            type: "table",
            label: this.$t("bill.carrierCode"),
            disabled: this.addflag,
            props: "carrierkey",
            tableConfig: [
              {
                label: this.$t("config.shipper"),
                prop: "storerkey",
                input: "input",
              },
              {
                label: this.$t("config.company"),
                prop: "company",
                input: "input",
              },
              {
                label: this.$t("config.city"),
                prop: "city",
                input: "input",
              },
              {
                label: this.$t("config.provice"),
                prop: "state",
                input: "input",
              },
              {
                label: this.$t("config.postcode"),
                prop: "zip",
                input: "input",
              },
              {
                label: this.$t("config.contact"),
                prop: "contact",
                input: "input",
              },
              {
                label: this.$t("config.phone"),
                prop: "phone",
                input: "input",
              },
            ],
            url: `/queryStorer/3/?/${this.$store.state.wms}`,
          },
        ],
      ];
    },
  },
  methods: {
    setdata(data, id, close, listId) {
      this.inputData.carrierkey = data.storerkey;
      close(false);
    },
  },
  mounted() {
    if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip;
      if (data.newFlag) {
        this.addflag = false;
      } else {
        this.addflag = true;
      }
    } else if (this.$store.state.newFlag) {
      this.addflag = false;
    } else {
      this.addflag = true;
    }
  },
  watch: {},
  components: {
    "v-details": details,
  },
};
</script>

<style scoped></style>
